package com.hangzhou.welbeing.welbeinginstrument.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hangzhou.welbeing.welbeinginstrument.R;
import com.hangzhou.welbeing.welbeinginstrument.inteface.OnRecyclerViewItemClickListener;

/**
 * 时间 2017 年 09 月 23.
 * 作者 Administrator  刘传华
 * 公司 杭州惟君医疗科技有限公司
 * 包名 com.hangzhou.welbeing.pregnant.welbeing_pregnant.adapter
 * 工程名 welbeing_pregnant
 */
public class MyDeviceAdapter extends RecyclerView.Adapter<MyDeviceAdapter.ViewHolder> implements View.OnClickListener{
    private OnRecyclerViewItemClickListener mOnItemClickListener = null;
    public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_my_devcie, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        view.setOnClickListener(this);
        return viewHolder;
    }

    //将数据与界面进行绑定的操作
    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
      /*  holder.tv_name.setText(data.get(position).name);
        holder.tv_remove_binding.setText("解除绑定");
        Glide.with(welbeingApp.getContext()).load(RBConstants.SERVER_URL+data.get(position).url1).into( holder.iv_binding_imag);*/
    }

    //获取数据的数量
    @Override
    public int getItemCount() {
        return 5;
    }

    @Override
    public void onClick(View v) {
        if(mOnItemClickListener != null ){
            mOnItemClickListener.onItemClick(v);
        }
    }

    //自定义的ViewHolder，持有每个Item的的所有界面元素
    public static class ViewHolder extends RecyclerView.ViewHolder {

        public TextView tv_name;
        public TextView tv_remove_binding;
        public ImageView iv_binding_imag;

        public ViewHolder(View view) {
            super(view);
            tv_name = (TextView) view.findViewById(R.id.item_my_devcie_tv_name);
            tv_remove_binding = (TextView) view.findViewById(R.id.item_my_devcie_tv_remove_binding);
            iv_binding_imag = (ImageView) view.findViewById(R.id.item_my_devcie_iv_binding_imag);

        }
    }
}
